/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cnd;

import java.util.EventListener;

/**
 *
 * @author marten
 */
public class SearchResults {

//    SearchResultTableModel p;
    private SearchResult[] results;
    SearchController searchController;

    public SearchResults(SearchController searchController) {
        this.searchController = searchController;
        results = new SearchResult[0];
    }

    public void addSearchResults(SearchResult[] add_results) {
        if (add_results != null) {
            if (add_results.length > 0) {
                SearchResult[] temp_results = new SearchResult[results.length +
                        add_results.length];
                System.arraycopy(results, 0, temp_results, 0, results.length);
                System.arraycopy(add_results, 0, temp_results, results.length,
                        add_results.length);
                results = temp_results;
                notifyListeners();
            }
        }
    }

    public void clearResults() {
        results = new SearchResult[0];
        notifyListeners();
    }

    public int getLength() {
        //System.out.println(results.length);
        return results.length;
    }

    public SearchResult[] getSearchResults() {
        return results;
    }

    public SearchResult getSearchResult(int r) {
        return results[r];
    }

/*    public void setParent(SearchResultTableModel p){
        this.p = p;
    }
*/
    private void notifyListeners() {
        searchController.updateSearchResultsTable();
        //p.fireTableDataChanged();
    }
}
